-
Notifications
You must be signed in to change notification settings - Fork 277
Conversation
If the base_url contains a query and/or a fragment, then the locatePath() delivers incorrect results. Example: ``` base_url: http://www.example.com/subsite/?language=de&abc=1#anchor path to visit: /user Result wrong: http://www.example.com/subsite/?language=de&abc=1#anchor/user Expected result: http://www.example.com/subsite/user?language=de&abc=1#anchor ``` This code is going to deal with all possible cases.
Could you also please add some tests to cover that new parsing logic? |
What is the reason to include a query string in a base url ? |
@stof the use case in a customer project is a multi lingual Drupal site where we need to make sure for each scenario that the test runs in a specific language. The only way to ensure that is with a query parameter, ?language=es as an example. @aik099 can you direct me too some samples on how you'd like to have those tests being written? |
@stof , I guess for parameters from that query string to be present on every built url.
@jurgenhaas , for this particular project I have no idea, because I contributed mostly to Mink itself and it's drivers. I might suggest looking at existing tests first and then creating something similar. |
I've tried an attempt for a test but without knowing which website is going to be tested I wonder which paths should be tested and how to make that test generic. Also, the test depends on what the base_url is which is defined in behat.yml and I have no influence on it. However, here is a pretty simple test and I hope to get some feedback on where to take it from here:
|
@jurgenhaas Actually, I think another expected result for your example could be
I think the proposed approach can lead to incomprehension, as it doesn't respect the RFCs regarding relative and absolute uris. Rather than putting everything in a single configuration option, what would you think about injecting two new configuration options: |
@csarrazi You are touching on a subject that is probably true but is different to the problem we're dealing with here. The fact that the base_url in my example already contains a path portion is not really relevant to the problem I am trying to solve and - more importantly - I'm not proposing any change on how the MinkExtension should handle base_url and path fragments. I'm only concerned about queries and fragments here. However, if what you're saying is a general issue in MinkExtension then it would of course make sense to build a central place which is dealing with all kinds of URL building with all possible scenarios. |
What I mean is that if you are on a browser with base uri If you target a link to For your use case, I think forcing a query or in all uris which are generated by the locatePath() method, by injecting two configuration would be the best. Let's keep in mind that Mink is a browser emulator. It should try to behave as closely as possible to the behavior of a real browser. This would even make your PR simpler, while still solving the issue. In the configuration, you would have something like: base_url: http://example.com/prefix/
base_query: { language: de, abc: 1 }
base_fragment: { anchor: ~ } In any case, that's just my two coppers. |
Right now we're not talking about controlling browser. The
So goal here is not to loose anything. The |
I'm not sure whether I'm really clear about this. This PR induces changes for both What I mean here is that, as it is now, this PR may have side-effects for people who wish to use one-time parameters (for setting the locale in the session, etc.). Parameters will thus be transferred every time a scenario will contain steps with the Query parameters and uri fragments can be used for two things:
From what I understand, this PR fixes the problem using the second approach. This means that if I wish to use the following statement
Then, the |
Isn't that what's the |
Taken from the documentation:
The documentation only describes Thus the suggestion before, by adding two new options for achieving this goal. |
Regardless, the
|
If the base_url contains a query and/or a fragment, then the locatePath() delivers incorrect results. Example:
This code is going to deal with all possible cases.